from typing import TypeVar, Generic, List, Optional

from pydantic import BaseModel, Field

T = TypeVar('T')


class ResumeSchema(BaseModel):
    id: int = Field(..., description="简历唯一ID")
    fileName: str = Field(..., description="文件名")
    createdAt: str = Field(..., description="提交时间")


class JobPostSchema(BaseModel):
    id: int = Field(default=None, description="工作岗位唯一ID", allow_none=True)
    recruiter_id: int = Field(..., description="招聘员ID")
    title: str = Field(..., description="工作岗位")
    company: str = Field(..., description="公司名称")
    location: str = Field(..., description="位置")
    salary: str = Field(..., description="薪酬")
    description: str = Field(default=None, description="岗位详细说明", allow_none=True)
    requirements: str = Field(default=None, description="岗位要求", allow_none=True)
    publish_date: str = Field(default=None, description="发布时间", allow_none=True)


class ResumeReportSchema(BaseModel):
    id: int = Field(..., description="简历报告唯一ID")
    resume_id: int = Field(..., description="分析报告唯一ID")
    resume_file_name: str = Field(..., description="文件名")
    match_rate: int = Field(..., description="匹配度")
    description: str = Field(..., description="分析报告详情")


class ApplicantSchema(BaseModel):
    report_id: int = Field(..., description="简历报告唯一ID")
    match_rate: float = Field(..., description="匹配度")
    description: Optional[str]
    status: int = Field(..., description="简历报告状态")
    job_seeker_id: int = Field(..., description="申请人ID")
    job_seeker_name: str = Field(..., description="申请人名称")
    resume_id: int = Field(..., description="简历唯一ID")
    resume_name: str = Field(..., description="简历文件名")
    job_post_id: int = Field(..., description="工作岗位ID")


class PaginationSchema(BaseModel, Generic[T]):
    sortBy: str = Field(default="id", description="排序列", allow_none=True)
    descending: bool = Field(default=False, description="降序", allow_none=True)
    page: int = Field(..., description="页码")
    rowsPerPage: int = Field(..., description="每页行数")
    rowsNumber: int = Field(..., description="总数")
    data: List[T] = Field(default=None, description="申请人ID", allow_none=True)

